import * as actionTypes from "./constance";
import {
  mvDetailF,
  mvDetailInfoF,
  mvUrlF,
  mvComment,
  allvideo,
} from "@/services/mv";

const mvDetail = (res) => ({
  type: actionTypes.GET_MV_DETAIL,
  mvDetails: res,
});

const mvDetailInfo = (res) => ({
  type: actionTypes.GET_MV_DETAIL_INFO,
  mvDetailInfo: res,
});

const mvUrl = (res) => ({
  type: actionTypes.GET_MV_URL,
  mvUrl: res,
});

const mvCommentInfo = (res) => ({
  type: actionTypes.GET_MV_COMMENT,
  mvComments: res,
});

const allvideoInfo = (res) => ({
  type: actionTypes.GET_MV_ALLVEDIO,
  allVideo: res,
});

export const mvDetailAction = (mvid) => {
  return (dispatch) => {
    mvDetailF(mvid).then((res) => {
      dispatch(mvDetail(res));
    });
  };
};

export const mvDetailInfoAction = (mvid) => {
  return (dispatch) => {
    mvDetailInfoF(mvid).then((res) => {
      dispatch(mvDetailInfo(res));
    });
  };
};

export const mvUrlAction = (id, r) => {
  return (dispatch) => {
    mvUrlF(id, r).then((res) => {
      dispatch(mvUrl(res));
    });
  };
};

export const mvCommentInfoAction = (id, limit, offset, before) => {
  return (dispatch) => {
    mvComment(id, limit, offset, before).then((res) => {
      dispatch(mvCommentInfo(res));
    });
  };
};

export const allvideoAction = (id) => {
  return (dispatch) => {
    allvideo(id).then((res) => {
      dispatch(allvideoInfo(res));
    });
  };
};
